home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- from __future__ import with_statement
- from __future__ import division
- import wx
- from util import autoassign, traceguard
- create_gc = wx.GraphicsContext.Create
- from gui.toolbox import TransparentBitmap
- from operator import itemgetter
- from cgui import Bitmap_Draw
- import new
- wx.Bitmap.Draw = new.instancemethod(Bitmap_Draw, None, wx.Bitmap)
-
- class MarginSizer(wx.GridBagSizer):
-
- def __init__(self, margins, content):
- wx.GridBagSizer.__init__(self)
- self.SetEmptyCellSize(wx.Size(0, 0))
- self.AddGrowableCol(1, 1)
- self.AddGrowableRow(1, 1)
- self.Add(content, (1, 1), flag = wx.EXPAND)
- self.SetMargins(margins)
-
-
- def SetMargins(self, margins):
- if len(self.GetChildren()) > 2:
- self.Detach(1)
- self.Detach(1)
-
- self.Add(wx.Size(margins.left, margins.top), (0, 0))
- self.Add(wx.Size(margins.right, margins.bottom), (2, 2))
-
-
-
- class Margins(list):
-
- def __init__(self, a = None):
- if a is None:
- list.__init__(self, [
- 0,
- 0,
- 0,
- 0])
- elif isinstance(a, basestring):
- list.__init__(self, (lambda .0: for c in .0:
- int(c))(a.split()))
- elif isinstance(a, int):
- list.__init__(self, [
- a] * 4)
- elif len(a) == 2:
- a = [
- a[0],
- a[1],
- a[0],
- a[1]]
-
- list.__init__(self, (lambda .0: for c in .0:
- int(c))(a))
-
-
- def Sizer(self, content):
- return MarginSizer(self, content)
-
- left = property(itemgetter(0))
- top = property(itemgetter(1))
- right = property(itemgetter(2))
- bottom = property(itemgetter(3))
- x = property((lambda self: self[0] + self[2]))
- y = property((lambda self: self[1] + self[3]))
- TopLeft = property((lambda self: wx.Point(self[0], self[1])))
- BottomRight = property((lambda self: wx.Point(self[2], self[3])))
-
- def __neg__(self):
- return []([ -a for a in self ])
-
-
-
- class SkinBase(object):
-
- def Show(self):
- wxSpriteShow = wxSpriteShow
- import gui.toolbox
- wxSpriteShow(self)
-
-
-
- class SkinRegion(SkinBase):
-
- def __init__(self, border = None, rounded = False, highlight = False, shadow = False):
- if not isinstance(border, (type(None), wx.Pen)):
- raise TypeError('border must be a Pen or None')
-
- autoassign(self, locals())
- self.pen = None if border is None else border
-
-
- def GetBitmap(self, size, n = 0):
- tb = TransparentBitmap(size)
- dc = wx.MemoryDC()
- dc.SelectObject(tb)
- self.draw(dc, wx.RectS(size), n)
- dc.SelectObject(wx.NullBitmap)
- return tb
-
-
- def Stroke(self, dc, gc, rect, n = 0):
- pen = self.pen
- penw = pen.Width // 2
- rect = wx.Rect(*rect)
- rect.Deflate(penw, penw)
- pen.SetCap(wx.CAP_PROJECTING)
- gc.SetPen(pen)
- dc.SetPen(pen)
- dc.Brush = wx.TRANSPARENT_BRUSH
- gc.Brush = wx.TRANSPARENT_BRUSH
- if self.rounded:
- if self.border:
- gc.DrawRoundedRectangle(*tuple(rect) + (self.rounded * 0.97,))
-
- rect.Inflate(penw, penw)
- self.stroke_highlights_rounded(gc, rect)
- elif self.border:
- offset = int(pen.Width % 2 == 0)
- dl = dc.DrawLine
- x = wx.Point(offset, 0)
- y = wx.Point(0, offset)
- for a, b in [
- (rect.TopLeft, rect.BottomLeft + y),
- (rect.BottomLeft + y, rect.BottomRight + y + x),
- (rect.BottomRight + y + x, rect.TopRight + x),
- (rect.TopRight + x, rect.TopLeft)]:
- dl(*tuple(a) + tuple(b))
-
-
- rect.Inflate(penw, penw)
- self.stroke_highlights(gc, rect)
-
-
- def stroke_highlights_rounded(self, gc, rect):
- pass
-
-
- def stroke_highlights(self, gc, rect):
- hw = max(2, self.pen.Width)
- seq = []
- if self.highlight:
- c1 = wx.Color(255, 255, 255, 100)
- c2 = wx.Color(255, 255, 255, 150)
- seq.extend([
- ((rect.x, rect.y), [
- (rect.x, rect.Bottom),
- (rect.x + hw, rect.Bottom - hw),
- (rect.x + hw, rect.y + hw),
- (rect.x, rect.y)], gc.CreateLinearGradientBrush(rect.x, rect.y, rect.x + hw, rect.y, c1, c2)),
- ((rect.x, rect.y), [
- (rect.Right + 1, rect.y),
- (rect.Right - hw, rect.y + hw),
- (rect.x + hw, rect.y + hw),
- (rect.x, rect.y)], gc.CreateLinearGradientBrush(rect.x, rect.y, rect.x, rect.y + hw, c1, c2))])
-
- if self.shadow:
- sc1 = wx.Color(0, 0, 0, 50)
- sc2 = wx.Color(0, 0, 0, 100)
- seq.extend([
- ((rect.Right + 1, rect.Bottom + 1), [
- (rect.x, rect.Bottom + 1),
- (rect.x + hw, (rect.Bottom - hw) + 1),
- ((rect.Right - hw) + 1, (rect.Bottom - hw) + 1),
- (rect.Right + 1, rect.Bottom + 1)], gc.CreateLinearGradientBrush(rect.x, (rect.Bottom - hw) + 1, rect.x, rect.Bottom + 1, sc1, sc2)),
- ((rect.Right + 1, rect.Bottom + 1), [
- (rect.Right + 1, rect.y),
- ((rect.Right - hw) + 1, rect.y + hw),
- ((rect.Right - hw) + 1, (rect.Bottom - hw) + 1),
- (rect.Right + 1, rect.Bottom + 1)], gc.CreateLinearGradientBrush((rect.Right - hw) + 1, rect.Bottom, rect.Right + 1, rect.Bottom, sc1, sc2))])
-
- if seq:
- for origin, pts, brush in seq:
- p = gc.CreatePath()
- p.MoveToPoint(*origin)
- for pt in pts:
- p.AddLineToPoint(*pt)
-
- gc.SetBrush(brush)
- gc.FillPath(p)
-
-
-
-
- def draw(self, *a, **k):
- self.Draw(*a, **k)
-
-
-
- class SkinStack(list, SkinBase):
-
- def __init__(self, seq):
- list.__init__(self, seq)
- if not all((lambda .0: for elem in .0:
- callable(getattr(elem, 'Draw', None)))(seq)):
- raise TypeError('SkinStack must be constructed with .Draw-able elements (you gave %r)' % seq)
-
-
-
- def Draw(self, dc, rect, n = 0):
- for brush in reversed(self):
- brush.Draw(dc, rect, n)
-
-
-
- def GetBitmap(self, size, n = 0):
- tb = TransparentBitmap(size)
- dc = wx.MemoryDC()
- dc.SelectObject(tb)
- for region in reversed(self):
- region.draw(dc, wx.RectS(size), n)
-
- dc.SelectObject(wx.NullBitmap)
- return tb
-
-
- def ytile(self):
- return all((lambda .0: for c in .0:
- c.ytile)(self))
-
- ytile = property(ytile)
-
-
- class SkinList(list, SkinBase):
-
- def __init__(self, seq):
- list.__init__(self, seq)
- if not all((lambda .0: for elem in .0:
- callable(getattr(elem, 'Draw', None)))(seq)):
- raise TypeError('SkinStack must be constructed with .Draw-able elements (you gave %r)' % seq)
-
-
-
- def Draw(self, dc, rect, n = 0):
- self[n % len(self)].Draw(dc, rect, n)
-
-
- def ytile(self):
- return all((lambda .0: for c in .0:
- c.ytile)(self))
-
- ytile = property(ytile)
-
-
- class SkinGradient(SkinRegion):
- __slots__ = [
- 'direction',
- 'ytile',
- 'colors',
- '_oldrect']
-
- def __init__(self, direction, colors, **opts):
- SkinRegion.__init__(self, **opts)
- self.direction = direction
- if direction == 'horizontal':
- pass
- self.ytile = not (self.border)
- self.colors = colors
- self._oldrect = None
- if self.rounded is not False or len(colors) > 2:
-
- self.Fill = lambda gc, x, y, w, h: wx.GraphicsContext.DrawRoundedRectangle(gc, x, y, w, h, self.rounded)
- else:
- self.Fill = wx.GraphicsContext.DrawRectangle
-
-
- def __repr__(self):
- return '<%s %s %r>' % (self.__class__.__name__, self.direction, self.colors)
-
-
- def _rects(self, therect):
- if therect == self._oldrect:
- return self._oldrects
-
- x = float(therect.x)
- y = float(therect.y)
- w = float(therect.width)
- h = float(therect.height)
- vert = self.direction == 'vertical'
- p1 = None(float if vert else therect.Left)
- lc = len(self.colors) - 1
- dx = None if vert else w / float(lc)
- rects = []
- for i in xrange(0, lc):
- (c1, c2) = self.colors[i:i + 2]
- delta = None if i not in (lc, 0) else 0
- if vert:
- r = (x, p1, w, dx + delta)
- gradrect = (x, p1 - delta, x, p1 + dx + delta * 2, c1, c2)
- else:
- r = (p1, y, dx + delta, h)
- gradrect = (p1 - delta, y, p1 + dx + delta * 2, y, c1, c2)
- rects.append((gradrect, r))
- p1 = p1 + dx
-
- return rects
-
-
- def Draw(self, dc, therect, n = 0):
- gc = create_gc(dc)
- gc.SetPen(wx.TRANSPARENT_PEN)
- createb = gc.CreateLinearGradientBrush
- gc.Clip(*therect)
- for gradrect, fillrect in self._rects(therect):
- gc.SetBrush(createb(*gradrect))
- self.Fill(gc, *fillrect)
-
- self.Stroke(dc, gc, therect)
-
-
-
- def SkinColorCGUI(color, **opts):
- SkinColor = SkinColor
- import cgui
- return SkinColor(color)
-
-
- class SkinColor(wx.Color, SkinRegion):
- simple = False
-
- def __init__(self, color, **opts):
- if not any((lambda .0: for key, val in .0:
- val)(opts.iteritems())):
- c = tuple(color)
- if len(c) < 4 or c[3] == 255:
- self.simple = True
-
-
- SkinRegion.__init__(self, **opts)
- wx.Color.__init__(self)
- self.Set(*color)
- self.ytile = not (self.border)
-
-
- def Fill(self, dc, rect):
- if self.rounded and not (self.simple):
- dc.DrawRoundedRectangle(*tuple(rect) + (self.rounded,))
- else:
- dc.DrawRectangle(*rect)
-
-
- def __repr__(self):
- return '<%s (%s, %s, %s, %s)>' % ((self.__class__.__name__,) + tuple(self))
-
-
- def Draw(self, dc, rect, n = 0):
- brush = wx.Brush(self)
- if self.simple:
- dc.SetPen(wx.TRANSPARENT_PEN)
- dc.SetBrush(brush)
- dc.DrawRectangle(*rect)
- else:
- gc = create_gc(dc)
- gc.SetBrush(brush)
- gc.SetPen(wx.TRANSPARENT_PEN)
- gc.Clip(*rect)
- self.Fill(gc, rect)
- self.Stroke(dc, gc, rect, n)
-
-
-